﻿using UnityEngine;
using System.Collections;

public class PontController : MonoBehaviour {
	
	public static bool moving = false;
	public float speed;
	private float ValeurMaxPont = 8.0f;
	private float positionCourante;
	private float positionDebut;

	public Transform picCollider;
	
	void Start () {
		positionDebut = transform.position.x;
	}

	void Update () {

		positionCourante = transform.position.x;

		if ((moving) && (transform.position.x <= ValeurMaxPont)){
				if(positionCourante <= (positionDebut + 1.3)) 
				{

					transform.position += new Vector3 (speed * Time.deltaTime, 0, 0);
					// move pic colliders
					picCollider.position += new Vector3 (speed * Time.deltaTime, 0, 0);

				}

				else {
					moving = false;
					positionDebut = positionCourante;
				}
		}
		else positionDebut = positionCourante;				
	} 
}
